package com.ysy.logistics.entities.system.vo;

import com.ysy.common.util.SaltMD5Util;
import com.ysy.logistics.entities.system.SysUser;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * @ClassDescription:
 * @Author:姚斯羽
 * @Create:2025/3/23 16:29
 **/
@Data
@Schema(name = "RestInfoVo",description = "更新个人资料实体类")
public class RestInfoVo {
    @Schema(description = "姓名")
    private String nickname;
    @Schema(description = "电话")
    private String phone;
    @Schema(description = "邮箱")
    private String email;
    @Schema(description = "性别")
    private String sex;

    @Schema(description = "旧密码")
    private String oldPassword;
    @Schema(description = "新密码")
    private String newPassword;
    @Schema(description = "确认密码")
    private String confirmPassword;

    /**
     * 基本资料修改
     * @return
     */
    public  SysUser convertToBaseSysUser(String id) {
        SysUser sysUser = new SysUser();
        sysUser.setId(id);
        sysUser.setNickname(this.nickname);
        sysUser.setPhone(this.phone);
        sysUser.setEmail(this.email);
        sysUser.setSex(this.sex);
        return sysUser;
    }

    /**
     * 修改密码
     * @param id
     * @return
     */
    public  SysUser convertToPasswordSysUser(String id) {
        SysUser sysUser = new SysUser();
        sysUser.setId(id);
        sysUser.setPassword(SaltMD5Util.generateSaltPassword(this.newPassword));
        return sysUser;
    }
}
